import Mock from 'mockjs'

//---------------------------------------------------------------------------

//提醒发送数据
const { data } = Mock.mock({
    "data|5": [
   {
            'Type|1': ['张天天', '刘星', '小雨', ],
            'aheader|1': ['一年级一班',"一年级二班",'二年级一班','三年级二班'],
            'range':'感冒药,一天吃三次,一次一颗', 
            'day':'2022-02-07',
            'nUploader|1': ['张天天妈妈','刘星爸爸','小雨姐姐'],
            'ddtime|1':['2022-02-07 15:27','2022-02-07 14:00'],
            'id':'@guid',
            'jsr|1':['杨老师','李老师']
            
        }
    ]
})


//渲染发布列表接口
Mock.mock('/healthylist', 'get', () => {
    return data;
})


//删除数据的接口
Mock.mock('/dalhealthy', 'post',(config)=>{
    const req =JSON.parse(config.body)

    let res ={
        code:200,
        mag:'删除失败'
    }
    data.forEach((item,index) => {
        if(item.id==req.id){
            data.splice(index,1)
            res.mag='删除成功'
        }
    });
    return res
})


//增加数据的接口

Mock.mock('/addhealthy','post',(config)=>{
    const req  = JSON.parse(config.body)
    data.push(req)
    return{
        code :200,
        mag:'添加成功'
    }
})